<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/2/12
 * Time: 11:30 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access.
defined('_JEXEC') or die;

// Include dependancy of the main controllerform class
jimport('joomla.application.component.controllerform');

class VastControllerQuanlykhenthuong extends JControllerForm
{

    public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true))
    {
        return parent::getModel($name, $prefix, array('ignore_request' => false));
    }

    public function delete()
    {
        // Initialise variables.
        $app    = JFactory::getApplication();
        $model  = $this->getModel('khenthuong');

        $id = JRequest::getInt('id', 0);
        $khenthuongid = JRequest::getInt('khenthuongid', 0);
                
        // Now update the loaded data to the database via a function in the model
        $deleteitem = $model->deleteItem($khenthuongid);
                
        // check if ok and display appropriate message.  This can also have a redirect if desired.
        if ($deleteitem) {
            $this->setMessage('Thông tin khen thưởng đã được xóa thành công');
            $this->setRedirect(JRoute::_('index.php?option=com_vast&context=quanlykhenthuong&view=quanlykhenthuong&id=' . $id));
        } else {
            $this->setMessage('Thông tin khen thưởng không được xóa thành công có lỗi đã xảy ra!', 'warning');
            $this->setRedirect(JRoute::_('index.php?option=com_vast&context=quanlykhenthuong&view=quanlykhenthuong&id=' . $id));
            return false;
        }

        return true;
    }

}